<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table){
            $table->increments('id');
            $table->string('nick_name')->default('')->comment('微信昵称');
            $table->string('avatar')->comment('头像');
            $table->string('country_code')->nullable()->comment('手机区号');
            $table->string('mobile')->nullable()->comment('手机');
            $table->string('open_id')->unique()->comment('微信open_id');
            $table->string('session_key')->nullable()->comment('session_key');
            $table->string('union_id')->nullable()->unique()->comment('微信union_id');
            $table->string('invite_code')->default('')->comment('邀请码');
            $table->integer('inviter_id')->default(0)->comment('邀请人ID');
            $table->string('channel')->default('')->comment('来源渠道');
            $table->string('api_token')->unique()->comment('api_token');

            $table->integer('word_ct')->default(0)->comment('学习单词数');
            $table->integer('complete_book_ct')->default(0)->comment('学习完成书本数');
            $table->integer('read_book_ct')->default(0)->comment('学习书本数');


            $table->integer('last_active_time')->default(0)->comment('最后活跃时间');
            $table->string('city')->default('')->comment('城市');
            $table->string('province')->default('')->comment('省份');
            $table->string('country')->default('')->comment('国家');
            $table->string('sex')->default('')->comment('性别');
            $table->rememberToken();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
